import java.time.LocalDateTime;


@Service
public class UserServiceImpl {

    @Autowired
    UserMapper userMapper;

    /**
     *  新增员工
     * */
    @Override
    public void addEmp(User user) {
        user.setCreateTime(LocalDateTime.now());
        user.setUpdateTime(LocalDateTime.now());
        userMapper.addEmp(user);
    }

    /**
     *  删除员工
     * */
    @Override
    public void deleteEmp(Integer id) {
        userMapper.deleteEmp(id);
    }

    /**
     *  查询员工
     * */
    @Override
    public User queryUserById(Integer id) {
        return userMapper.queryUserById(id);
    }
    /**
     * 修改
     * */
    @Override
    public void updateUser(User user) {
        user.setUpdateTime(LocalDateTime.now());
        userMapper.updateUser(user);
    }

    /**
     *  分页查询
     * */
    @Override
    public List<User> queryUserByPage(Integer page, Integer size) {
        return userMapper.queryUserByPage((page-1)*size,size);
    }
}
